<?php
/**
 * True Gallery back-end edit picture template file
 *
 * @version 2.5
 * @author Alexey N. Brin (userxp@joomlaportal.ru)
 * @homepage http://truegallery.ru 
 * @filename admin.pictures.edit.tpl.php
 * @package True Gallery
 * @copyright (C) 2008-2009 by joomlatune.ru
 * @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
 * 
 * THIS GALLERY is an EVOLUTION of AkoGallery -> PonyGallery -> DatsoGallery
 *
 * If you fork this to create your own project, 
 * please make a reference to True Gallery someplace in your code 
 * and provide a link to http://www.joomlatune.ru
 *
 **/

defined('_VALID_MOS') or defined('_JEXEC') or die('Direct Access to this location is not allowed.');

//xdump( $row );
?>
<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminheading">
	<tr>
		<th class="tg_adminheader tg_categories">
			<?php echo $header; ?>
		</th>
	</tr>
</table>

<table border="0" cellspacing="0" cellpadding="6" style="table-layout: auto; white-space: nowrap;">
	<tr>
		<td align="left" valign="top">
			<form action="<?php echo TRUE_INDEX2; ?>&view=pictures&task=show" method="post" name="adminForm" id="adminForm">
				<table cellpadding="4" cellspacing="1" border="0">
					<tr>
						<td><b><?php echo JText::_('TG_TITLE'); ?>:</b></td>
						<td><input class="inputbox" type="text" name="imgtitle" size="39" maxlength="100" value="<?php echo htmlspecialchars($row->imgtitle, ENT_QUOTES); ?>" /></td>
						<td rowspan="8" valign="top" width="230">
							<!--div class="true_picture" style="float:left;width:45% !important;"-->
							<?php 
							$filepath = $row->catid . DSX . $row->imgfilename;
							$fileway = $row->catid . '/' . $row->imgfilename;
							$info = getimagesize( TG_ORIGINALSPATH. $row->catid . DSX . $row->imgfilename );
							$size = filesize( TG_ORIGINALSPATH. $row->catid . DSX . $row->imgfilename );
							$type = array( 1 => 'GIF', 2 => 'JPG', 3 => 'PNG' );
							$info[2] = $type[$info[2]];
							$fsize = format_filesize($size);
							$imgthumb = TG_THUMBSWAY.$row->catid.'/'.$row->imgfilename;
							
							ob_start();
							// http://l.j15/avto/images/trueimg/thumbs/8/7B5A0E6865FA-8.jpg
							// index.php?option=com_true&view=pictures&task=show&catid=8&id=246&size=0&ax=1&no_html=1&Itemid=156
							$link =  JTuneConfig::getCfg('live_site').'/index.php?option='.TG_CMP;
							$link .= '&view=pictures&task=show&catid='.$row->catid.'&id='.$row->id.'&size=%d';
							$link .= '&ax=1&no_html=1&Itemid=156';
							//$link = sprintf( $link, 0 );
							?>
							<div>
								<!--a target="_blank" rel="lightbox-tour" href="<?php echo TG_THUMBSWAY.$fileway; ?>"><?php echo JText::_('TG_THUMB_PIC_PREVIEW'); ?></a> |
								<a target="_blank" rel="lightbox-tour" href="<?php echo TG_PICTURESWAY.$fileway; ?>"><?php echo JText::_('TG_MED_PIC_PREVIEW'); ?></a> | 
								<a target="_blank" rel="lightbox-tour" href="<?php echo TG_ORIGINALSWAY.$fileway; ?>"><?php echo JText::_('TG_ORG_PIC_PREVIEW'); ?></a-->
								<a target="_blank" rel="lightbox-tour" href="<?php echo sprintf( $link, 2 ); ?>"><?php echo JText::_('TG_THUMB_PIC_PREVIEW'); ?></a> |
								<a target="_blank" rel="lightbox-tour" href="<?php echo sprintf( $link, 1 ); ?>"><?php echo JText::_('TG_MED_PIC_PREVIEW'); ?></a> | 
								<a target="_blank" rel="lightbox-tour" href="<?php echo sprintf( $link, 0 ); ?>"><?php echo JText::_('TG_ORG_PIC_PREVIEW'); ?></a>
							</div>
							<?php
							$c = ob_get_contents();
							ob_end_clean();
							?>
							
							<?php ob_start(); ?>
								<div><?php echo 'File: '.$ad_path.'/'.$row->catid.'/'.$row->imgfilename; ;?></div>
								<?php echo getRoundedTab( $c, 'element-box' ); ?>
								<div>
									<fieldset>
										<legend>&nbsp;<?php echo JText::_('TG_ORG_PIC_INFO'); ?>&nbsp;</legend>
										<div><img src="<?php echo $imgthumb; ?>" style="<?php echo $ad_imgstyle; ?>" title="<?php echo JText::_('TG_THUMB_PIC_PREVIEW'); ?>" /></div>
										<div><?php echo JText::_('TG_SIZE'); ?>: <?php echo $info[0].' X '.$info[1]; ?></div>
										<div><?php echo JText::_('TG_ORG_TYPE'); ?>: <?php echo $info[2]; ?></div>
										<div><?php echo JText::_('TG_FILESIZE'); ?>: <?php echo $fsize; ?></div>
									</fieldset>
								</div>
							<?php
							$c = ob_get_contents();
							ob_end_clean();
							echo getRoundedTab( $c );
							?>
							<!--/div-->
						</td>
					</tr>
					<tr>
						<td><b><?php echo JText::_('TG_PUBLISHED'); ?>:</b></td>
						<td><?php echo $publist; ?></td>
					</tr>
					<tr>
						<td><b><?php echo JText::_('TG_ALIAS'); ?>:</b></td>
						<td>
							<input class="inputbox" type="text" name="alias" size="39" value="<?php echo $row->alias; ?>">
							<div id="aliascheck"></div>
						</td>
					</tr>
					<tr>
						<td valign="top"><b><?php echo JText::_('TG_CATEGORY'); ?>:</b></td>
						<td><?php echo $clist; ?></td>
					</tr>
					
					<tr>
						<td valign="top"><b><?php echo JText::_('TG_ORDERING'); ?>:</b></td>
						<td><?php echo $imagelist; ?></td>
					</tr>							
					
					<tr>
						<td><b><?php echo JText::_('TG_FIELD1'); ?>:</b></td>
						<td><?php if( class_exists( 'JFactory' ) ) {
								echo JHTML::calendar( $row->field1, 'field1', 'field1' );
							} else { ?>
							<input class="inputbox" type="text" name="field1" id="field1" size="39" maxlength="100" value="<?php echo htmlspecialchars($row->field1, ENT_QUOTES); ?>" />
							<input type="reset" class="button" value="..." onClick="return showCalendar('field1', 'y-mm-dd');">
							<?php } ?>
						</td>
					</tr>
					<tr>
						<td><b><?php echo JText::_('TG_FIELD2'); ?>:</b></td>
						<td><input class="inputbox" type="text" name="field2" size="39" maxlength="100" value="<?php echo htmlspecialchars($row->field2, ENT_QUOTES); ?>" /></td>
					</tr>
					<tr>
						<td><b><?php echo JText::_('TG_FIELD3'); ?>:</b></td>
						<td><input class="inputbox" type="text" name="field3" size="39" maxlength="100" value="<?php echo htmlspecialchars($row->field3, ENT_QUOTES); ?>" /></td>
					</tr>
					<tr>
						<td><b><?php echo JText::_('TG_FIELD4'); ?>:</b></td>
						<td><input class="inputbox" type="text" name="field4" size="39" maxlength="100" value="<?php echo htmlspecialchars($row->field4, ENT_QUOTES); ?>" /></td>
					</tr>
					<tr>
						<td><b><?php echo JText::_('TG_FIELD5'); ?>:</b></td>
						<td><input class="inputbox" type="text" name="field5" size="39" maxlength="100" value="<?php echo htmlspecialchars($row->field5, ENT_QUOTES); ?>" /></td>
					</tr>
					<tr>
						<td valign="top" align="left"><b><?php echo JText::_('TG_DESCRIPTION'); ?>:</b></td>
						<td colspan="2">
							<?php editorArea('editor1', str_replace('&', '&amp;', $row->imgtext), 'imgtext', '500', '200', '70', '10'); ?>
						</td>
					</tr>
					<tr>
						<td valign="top"><b><?php echo JText::_('TG_AUTHOR_OWNER'); ?>:</b></td>
						<td colspan="2"><input class="inputbox" type="text" name="imgauthor" value="<?php echo $row->imgauthor; ?>" size="39" maxlength="100" /></td>
					</tr>
					<tr>
						<td valign="top"><b><?php echo JText::_('TG_METADESC'); ?>:</b></td>
						<td colspan="2"><input class="inputbox" type="text" name="metadesc" value="<?php echo $row->metadesc; ?>" size="100" maxlength="200" /></td>
					</tr>
					<tr>
						<td valign="top"><b><?php echo JText::_('TG_METAKEY'); ?>:</b></td>
						<td colspan="2"><input class="inputbox" type="text" name="metakey" value="<?php echo $row->metakey; ?>" size="100" maxlength="200" /></td>
					</tr>
					<!--<tr>
						<td valign="top"><b><?php echo JText::_('TG_TAGS'); ?>:</b></td>
						<td><input class="inputbox" type="text" name="tags" value="<?php echo $row->tags; ?>" size="100" maxlength="200" /></td>
					</tr>/-->
				</table>
				<input type="hidden" name="id" value="<?php echo $row->id; ?>" />
				<!--input type="hidden" name="imgoriginalname" value="<?php //echo $row->imgoriginalname; ?>" /-->
				<!--input type="hidden" name="imgthumbname" value="<?php //echo $row->imgthumbname; ?>" /-->
				<input type="hidden" name="imgfilename" value="<?php echo $row->imgfilename; ?>" />
				<input type="hidden" name="option" value="<?php echo TG_CMP; ?>" />
				<input type="hidden" name="oldcatid" value="<?php echo $row->catid; ?>" />
				<input type="hidden" name="task" value="show" />
				<input type="hidden" name="view" value="pictures" />
				<input type="hidden" name="owner" value="<?php 
					if($row->owner) {
						echo $row->owner;
					} else {
						echo $my->username;
					} ?>" />
				<input type="hidden" name="approved" value="<?php 
					if( $row->approved == '' ) {
						echo '1';
					} else {
						echo $row->approved;
					} ?>" />
			</form>
		</td>
	</tr>
</table>

<?php if( !TG_AJAX ) { ?>
<script type="text/javascript">
function submitbutton(pressbutton) {
	var form = document.adminForm;
	if (pressbutton == 'cancel') {
		submitform( pressbutton );
		return;
	}
	if (form.imgtitle.value == ""){
		alert( "1-<?php echo JText::_('TG_PIC_ENTER_TITLE'); ?>" );
	} else if (form.catid.value == "0"){
		alert( "2-<?php echo JText::_('TG_SELECT_CAT'); ?>" );
		//} else if (form.imgoriginalname.value == ""){
		//	alert( "<?php echo JText::_('TG_SELECT_ORG_PIC'); ?>" );
	} else if (form.imgfilename.value == ""){
		alert( "3-<?php echo JText::_('TG_SELECT_MED_PIC'); ?>" );
		//} else if (form.imgthumbname.value == ""){
		//	alert( "<?php echo JText::_('TG_SELECT_THUMB_PIC'); ?>" );
	} else {
		submitform( pressbutton );
	}
}
</script>
<?php 
//echo JTrueGalleryHTMLHelper::linkJSCalendar(); // J1.0/Js1.2 Only
}